package com.rk.hosp.controller;

import com.rk.common.result.Result;
import com.rk.hosp.model.hosp.Schedule;
import com.rk.hosp.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author :Rk.
 * @date : 2022/11/17
 */
@Slf4j
@RestController
@Api(tags = "排班管理接口")
@RequestMapping("/admin/hosp/schedule")
//@CrossOrigin
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;


    @ApiOperation(value = "查询排版规则数据")
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(
            @PathVariable Integer page,
            @PathVariable Integer limit,
            @PathVariable String hoscode,
            @PathVariable String depcode
    ){
        try {
            Map<String, Object> ruleSchedule = scheduleService.getRuleSchedule(page, limit, hoscode, depcode);
            return Result.ok(ruleSchedule);
        }catch (Exception e){
            return Result.fail("查询失败!");
        }
    }

    @ApiOperation(value = "查询排班信息医院详情")
    @GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getDetailSchedule(@PathVariable  String hoscode,
                                    @PathVariable String depcode,
                                    @PathVariable String workDate){
        List<Schedule> detailScheduleList = scheduleService.getDetailSchedule(hoscode, depcode, workDate);
        return Result.ok(detailScheduleList);
    }


    
}
